package com.mdd.car.controller;

import com.mdd.car.params.CarSeriesParam;
import com.mdd.car.service.ICarSeriesService;
import com.mdd.car.vo.CarSeriesVo;
import com.mdd.common.aop.NotPower;
import com.mdd.common.base.page.PageValidate;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validate.AddGroup;
import com.mdd.common.validate.EditGroup;
import com.mdd.common.validate.IdsValidate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 车系管理
 *
 * @Description
 * @Author 幻速
 * @Date 2024/3/13 13:43
 **/
@RestController
@RequestMapping("api/system/car/series")
@Api(tags = "车系管理")
public class SysCarSeriesController {
    @Resource
    ICarSeriesService carSeriesService;
    @NotPower
    @GetMapping("/all")
    @ApiOperation(value="所有车系")
    public AjaxResult<List<CarSeriesVo>> all() {
        List<CarSeriesVo> list = carSeriesService.all();
        return AjaxResult.success(list);
    }
    @NotPower
    @GetMapping("/list")
    @ApiOperation(value="车系列表")
    public AjaxResult<PageResult<CarSeriesVo>> list(@Validated PageValidate pageValidate,String name) {
        PageResult<CarSeriesVo> list = carSeriesService.list(pageValidate,name);
        return AjaxResult.success(list);
    }
    @NotPower
    @PostMapping("/add")
    @ApiOperation(value="车系新增")
    public AjaxResult<Object> add(@Validated(value = AddGroup.class) @RequestBody CarSeriesParam carBrandParam) {
        carSeriesService.add(carBrandParam);
        return AjaxResult.success();
    }
    @NotPower
    @PostMapping("/edit")
    @ApiOperation(value="车系编辑")
    public AjaxResult<Object> edit(@Validated(value = EditGroup.class) @RequestBody CarSeriesParam carBrandParam) {
        carSeriesService.edit(carBrandParam);
        return AjaxResult.success();
    }
    @NotPower
    @PostMapping("/del")
    @ApiOperation(value="车系删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdsValidate idValidate) {
        carSeriesService.del(idValidate.getIds());
        return AjaxResult.success();
    }
}
